//
//  ByBasketBalllListValueView.m
//  caipiao_ios
//
//  Created by mc on 2018/9/7.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "ByBasketBalllListValueView.h"
#import "ByValueView.h"
#import "ByFootBallTitleValueView.h"


@implementation ByBasketBalllListValueView

- (id)init{
    self = [super init];
    if (self) {
        
    }
    return self;
}

- (void)setType:(NSInteger)type{
    _type = type;
}

- (void)setNetModel:(ByNetModel *)netModel{
    _netModel = netModel;
    [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];

    if (self.type == 0){
        
        self.backgroundColor = rgba(246, 246, 246, 1);
        self.layer.borderWidth = 1;
        self.layer.borderColor = [UIColor lightGrayColor].CGColor;
        
        CGFloat top = 10;
        for (int i = 0; i < 5; i++){
            ByFootBallTitleValueView *titleValueView = [[ByFootBallTitleValueView alloc] init];
            [self addSubview:titleValueView];
            if (i == 0) {
                titleValueView.titleLabel.text = @"非让分:";
                titleValueView.valueLabel.text = netModel.selectedSfString;
                [titleValueView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(self).offset(10);
                    make.right.equalTo(self).offset(0);
                    make.top.equalTo(self).offset(top);
                    make.height.mas_equalTo(@([ByFootBallTitleValueView  getHeightWithDataString:netModel.selectedSfString]));
                }];
                if (netModel.selectedSfString.length == 0) {
                    titleValueView.hidden = YES;
                }
                top = top + [ByFootBallTitleValueView  getHeightWithDataString:netModel.selectedSfString];
                
            }else if (i == 1){
                titleValueView.titleLabel.text = @"让分:";
                titleValueView.valueLabel.text = netModel.selectedRsfString;
                [titleValueView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(self).offset(10);
                    make.right.equalTo(self).offset(0);
                    make.top.equalTo(self).offset(top);
                    make.height.mas_equalTo(@([ByFootBallTitleValueView  getHeightWithDataString:netModel.selectedRsfString]));
                }];
                if (netModel.selectedRsfString.length == 0) {
                    titleValueView.hidden = YES;
                }
                top = top + [ByFootBallTitleValueView  getHeightWithDataString:netModel.selectedRsfString];
                
            }else if (i == 2){
                
                titleValueView.titleLabel.text = @"大小分:";
                titleValueView.valueLabel.text = netModel.selectedBigSmallString;
                [titleValueView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(self).offset(10);
                    make.right.equalTo(self).offset(0);
                    make.top.equalTo(self).offset(top);
                    make.height.mas_equalTo(@([ByFootBallTitleValueView  getHeightWithDataString:netModel.selectedBigSmallString]));
                }];
                if (netModel.selectedBigSmallString.length == 0) {
                    titleValueView.hidden = YES;
                }
                top = top + [ByFootBallTitleValueView  getHeightWithDataString:netModel.selectedBigSmallString];
                
            }else if (i == 3){
                titleValueView.titleLabel.text = @"主胜:";
                titleValueView.valueLabel.text = netModel.sfcSelectedString1;
                [titleValueView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(self).offset(10);
                    make.right.equalTo(self).offset(0);
                    make.top.equalTo(self).offset(top);
                    make.height.mas_equalTo(@([ByFootBallTitleValueView  getHeightWithDataString:netModel.sfcSelectedString1]));
                }];
                if (netModel.sfcSelectedString1.length == 0) {
                    titleValueView.hidden = YES;
                }
                top = top + [ByFootBallTitleValueView  getHeightWithDataString:netModel.sfcSelectedString1];
                
            }else if (i == 4){
                titleValueView.titleLabel.text = @"客胜:";
                titleValueView.valueLabel.text = netModel.sfcSelectedString2;
                [titleValueView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(self).offset(10);
                    make.right.equalTo(self).offset(0);
                    make.top.equalTo(self).offset(top);
                    make.height.mas_equalTo(@([ByFootBallTitleValueView  getHeightWithDataString:netModel.sfcSelectedString2]));
                }];
                if (netModel.sfcSelectedString2.length == 0) {
                    titleValueView.hidden = YES;
                }
                top = top + [ByFootBallTitleValueView  getHeightWithDataString:netModel.sfcSelectedString2];
                
            }
            
        }
        
        
    }else if (self.type == 1 || self.type == 2 || self.type == 3){
        
        ByNetModel *netModel1;
        ByNetModel *netModel2;
        
        if (self.type == 1){
            netModel1 = [netModel.sfArray firstObject];
            netModel2 = [netModel.sfArray objectAtIndex:1];
           
        }else if (self.type == 2){
            netModel1 = [netModel.rsfArray firstObject];
            netModel2 = [netModel.rsfArray objectAtIndex:1];
        }else{
            netModel1 = [netModel.bigSmallArray firstObject];
            netModel2 = [netModel.bigSmallArray objectAtIndex:1];
           
        }
        
        UILabel *vsLabel = [[UILabel alloc] init];
        [self addSubview:vsLabel];
        [vsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self).offset(0);
            make.top.equalTo(self).offset(0);
            make.bottom.equalTo(self).offset(0);
            make.size.mas_equalTo(CGSizeMake(50, 20));
        }];
        vsLabel.text = @"vs";
        vsLabel.textColor = [UIColor blackColor];
        vsLabel.textAlignment = NSTextAlignmentCenter;
        vsLabel.font = FONT(14);
        
        ByValueView *leftView = [[ByValueView alloc] init];
        [self addSubview:leftView];
        [leftView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(0);
            make.right.equalTo(vsLabel.mas_left).offset(-20);
            make.top.equalTo(self).offset(0);
            make.bottom.equalTo(self).offset(0);
        }];
        leftView.titleLabel.text = netModel1.title;
        leftView.valueLabel.text = netModel1.valueString;
        leftView.netModel = netModel1;
        
        ByValueView *rightView = [[ByValueView alloc] init];
        [self addSubview:rightView];
        [rightView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(vsLabel.mas_right).offset(20);
            make.right.equalTo(self).offset(0);
            make.top.equalTo(self).offset(0);
            make.bottom.equalTo(self).offset(0);
        }];
        
        rightView.titleLabel.text = netModel2.title;
        rightView.valueLabel.text = netModel2.valueString;
        rightView.netModel = netModel2;
        
        
        
    }else if (self.type == 4){
        self.backgroundColor = rgba(246, 246, 246, 1);
        self.layer.borderWidth = 1;
        self.layer.borderColor = [UIColor lightGrayColor].CGColor;
        
        CGFloat top = 10;
        for (int i = 0; i < 2; i++){
            ByFootBallTitleValueView *titleValueView = [[ByFootBallTitleValueView alloc] init];
            [self addSubview:titleValueView];
            if (i == 0) {
                titleValueView.titleLabel.text = @"主胜:";
                titleValueView.valueLabel.text = netModel.sfcSelectedString1;
                [titleValueView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(self).offset(10);
                    make.right.equalTo(self).offset(0);
                    make.top.equalTo(self).offset(top);
                    make.height.mas_equalTo(@([ByFootBallTitleValueView  getHeightWithDataString:netModel.sfcSelectedString1]));
                }];
                top = top + [ByFootBallTitleValueView  getHeightWithDataString:netModel.sfcSelectedString1];
                
            }else if (i == 1){
                titleValueView.titleLabel.text = @"客胜:";
                titleValueView.valueLabel.text = netModel.sfcSelectedString2;
                [titleValueView mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(self).offset(10);
                    make.right.equalTo(self).offset(0);
                    make.top.equalTo(self).offset(top);
                    make.height.mas_equalTo(@([ByFootBallTitleValueView  getHeightWithDataString:netModel.sfcSelectedString2]));
                }];
                top = top + [ByFootBallTitleValueView  getHeightWithDataString:netModel.sfcSelectedString2];
            }
        }
        
    }
}


@end
